<template>
  <el-form :inline="true" :model="name" class="form-inline">
    <el-row class="row">
      <el-form-item label="巡检点名称：">
        <el-input v-model="formInline.name" placeholder="--请输入--"></el-input>
      </el-form-item>
      <el-form-item label="巡检管廊：">
        <el-select v-model="formInline.pipeName" placeholder="请选择">
          <el-option
            v-for="item in pipeNameDrop"
            :key="item.id"
            :label="item.pipeName"
            :value="item.pipeName"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="巡检类型：" prop="patrolName">
        <el-select v-model="formInline.patrolName" placeholder="--请选择--">
          <el-option
            v-for="item in CheckingTypeDropList"
            :key="item"
            :label="item"
            :value="item"
          />
        </el-select>
      </el-form-item>
      <el-form-item class="btns">
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <el-button type="success" class="m-left" @click="onClear"
          >清空</el-button
        >
      </el-form-item></el-row
    >
  </el-form>
</template>

<script setup>
import { reactive, defineEmits, ref, onMounted } from 'vue'
import { commonPipeNameDrop } from '@/api/back'
import { CheckingTypeDrop } from '@/api/CheckingPoint'
onMounted(() => {
  GetpipeNameDrop()
  GetPmiPointTypeDrop()
})
const CheckingTypeDropList = ref([]) //巡检类型下拉列表
const pipeNameDrop = ref([]) //巡检管廊下拉列表
const date = ref([])
//获取巡检类型下拉列表
const GetPmiPointTypeDrop = () => {
  CheckingTypeDrop().then((res) => {
    let data = res
    console.log(data)
    CheckingTypeDropList.value = [...data]
  })
}
//获取巡检管廊下拉列表
const GetpipeNameDrop = () => {
  commonPipeNameDrop().then((res) => {
    let data = res
    pipeNameDrop.value = [...data]
  })
}
const formInline = reactive({
  name: '', //巡检点名称
  pipeName: '', //巡检管廊名称
  patrolName: '' //巡检类型
})

const emits = defineEmits(['onSearch'])
const onSubmit = () => {
  emits('onSearch', formInline)
}
const onClear = () => {
  formInline.name = ''
  formInline.pipeName = ''
  formInline.patrolName = ''

  emits('onSearch', formInline)
}
</script>

<style lang="scss" scoped>
.form-inline {
  .row {
    display: flex;
    flex-wrap: wrap;
    column-gap: 5%;
  }

  width: 100%;
  position: relative;
  // display: flex;
  // column-gap: 20px;
  // padding-bottom: 33px;
  // margin-top: -5px;
  .btns {
    position: absolute;
    right: 0;
    top: 4px;
    .m-left {
      margin-left: 20px;
    }
  }
}
</style>
